let c = 0
let mapData = [] //平面图坐标
let sensorData = [] //传感器坐标
let map
let label
let g = function(a) {
	return [
		[
			[a[0], a[2]],
			[a[0], a[3]],
			[a[1], a[3]],
			[a[1], a[2]],
			[a[0], a[2]]
		]
	]
}

//---------------------------------一层
sensorData[1] = [{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'left'
		},
		id: "lm_1_1",
		platId: "lm_1_1",
		name: "传感器",
		value: [1.9, 6.2]
	},
	{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'left'
		},
		id: "lm_1_2",
		platId: "lm_1_2",
		name: "传感器",
		value: [1.9, 1.5]
	},
	{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'right'
		},
		id: "m1_1",
		platId: "m1_1",
		name: "传感器",
		value: [3, 6.2]
	},
	{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'left'
		},
		id: "m1_2",
		platId: "m1_2",
		name: "传感器",
		value: [5, 6.2]
	},
	{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'bottom'
		},
		id: "o1_1",
		platId: "o1_1",
		name: "传感器",
		value: [7, 6.2]
	},
	{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'right'
		},
		id: "lo1_1_1",
		platId: "lo1_1_1",
		name: "传感器",
		value: [8.1, 6]
	},
	{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'right'
		},
		id: "lo1_1_2",
		platId: "lo1_1_2",
		name: "传感器",
		value: [8.1, 1.5]
	},
	{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'bottom'
		},
		id: "o1_2_5",
		platId: "o1_2_5",
		name: "传感器",
		value: [6, 2.8]
	},
	{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'bottom'
		},
		id: "o1_6",
		platId: "o1_6",
		name: "传感器",
		value: [2.5, 2.8]
	}
]

map = mapData[1] = {}
label = [0, 5.3]
// map["一层平面图" + "_" + c++] = [[label,label,label,label,label]]
map["" + "_" + c++] = g([0, 10, 0, 8]) //整个区域
map["" + "_" + c++] = g([2, 3, 0, 0.5]) //入口
map["大会议室" + "_" + c++] = g([0, 2, 0, 8])
map["小会议室" + "_" + c++] = g([2, 4, 6, 8])
map["小会议室" + "_" + c++] = g([4, 5.5, 6, 8])
let arr = [
	[6, 7],
	[6, 8],
	[8, 8],
	[8, 7]
]
map["" + "_" + c++] = [
	[...arr, ...(arr.reverse())]
] //更衣室大块
map["更衣室" + "_" + c++] = g([6, 6.8, 6, 7])
map["更衣室" + "_" + c++] = g([7.2, 8, 6, 7])

map["楼梯" + "_" + c++] = g([2, 3, 3, 5])
map["" + "_" + c++] = g([2, 2.2, 3, 5]) //楼梯左边空的部分

map["" + "_" + c++] = g([3.5, 4, 3, 3.3]) //强电井
map["电梯" + "_" + c++] = g([3.5, 4, 3, 5])
map["" + "_" + c++] = g([3.5, 4, 4.7, 5]) //强电井

map["" + "_" + c++] = g([5, 7, 3, 5]) //整个大块
arr = [
	[5.8, 4],
	[5, 4],
	[5, 5],
	[7, 5],
	[7, 4],
	[6.2, 4]
]
map["" + "_" + c++] = [
	[...arr, ...(arr.reverse())]
] //整个卫生间
map["卫生间" + "_" + c++] = g([5, 7, 4, 5])
map["软水间" + "_" + c++] = g([5, 5.8, 3, 4])
map["清扫间" + "_" + c++] = g([6.2, 7, 3, 4])
map["" + "_" + c++] = g([5.8, 6.2, 3, 3.3]) //水暖井

map["楼梯" + "_" + c++] = g([7.5, 8, 3, 5])
map["" + "_" + c++] = g([7.5, 8, 4.7, 5]) //弱电井

map["开敞办公室" + "_" + c++] = g([8, 10, 0, 8])

//---------------------------------二层
sensorData[2] = [{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'left'
		},
		id: "lo2_1_1",
		platId: "lo2_1_1",
		name: "传感器",
		value: [1.9, 6.2]
	},
	{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'left'
		},
		id: "lo2_1_2",
		platId: "lo2_1_2",
		name: "传感器",
		value: [1.9, 1.5]
	},
	{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'right'
		},
		id: "o2_1",
		platId: "o2_1",
		name: "传感器",
		value: [2.5, 6.2]
	},
	{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'right'
		},
		id: "o2_2",
		platId: "o2_2",
		name: "传感器",
		value: [3.5, 6.2]
	},
	{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'right'
		},
		id: "o2_3",
		platId: "o2_3",
		name: "传感器",
		value: [6.5, 6.2]
	},
	{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'right'
		},
		id: "o2_4",
		platId: "o2_4",
		name: "传感器",
		value: [7.5, 6.2]
	},
	{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'right'
		},
		id: "o2_5",
		platId: "o2_5",
		name: "传感器",
		value: [2.5, 1.8]
	},
	{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'right'
		},
		id: "o2_6",
		platId: "o2_6",
		name: "传感器",
		value: [3.5, 1.8]
	},
	{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'right'
		},
		id: "o2_7",
		platId: "o2_7",
		name: "传感器",
		value: [4.5, 1.8]
	},
	{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'right'
		},
		id: "o2_8",
		platId: "o2_8",
		name: "传感器",
		value: [5.5, 1.8]
	},
	{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'right'
		},
		id: "o2_9",
		platId: "o2_9",
		name: "传感器",
		value: [6.5, 1.8]
	},
	{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'right'
		},
		id: "o2_10",
		platId: "o2_10",
		name: "传感器",
		value: [7.5, 1.8]
	},
	{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'right'
		},
		id: "m2_1",
		platId: "m2_1",
		name: "传感器",
		value: [5, 6.2]
	},
	{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'right'
		},
		id: "lo2_2_1",
		platId: "lo2_2_1",
		name: "传感器",
		value: [8.1, 6]
	},
	{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'right'
		},
		id: "lo2_2_2",
		platId: "lo2_2_2",
		name: "传感器",
		value: [8.1, 1.5]
	},
]

map = mapData[2] = {}
// map["一层平面图" + "_" + c++] = [[label,label,label,label,label]]
map["" + "_" + c++] = g([0, 10, 0, 8]) //整个区域
map["开敞办公室" + "_" + c++] = g([0, 2, 0, 8])
map["办公室1" + "_" + c++] = g([2, 3, 6, 8])
map["办公室2" + "_" + c++] = g([3, 4, 6, 8])
map["会议室1" + "_" + c++] = g([4, 6, 6, 8])
map["办公室3" + "_" + c++] = g([6, 7, 6, 8])
map["办公室4" + "_" + c++] = g([7, 8, 6, 8])
map["办公室5" + "_" + c++] = g([2, 3, 0, 2])
map["办公室6" + "_" + c++] = g([3, 4, 0, 2])
map["办公室7" + "_" + c++] = g([4, 5, 0, 2])
map["办公室8" + "_" + c++] = g([5, 6, 0, 2])
map["办公室9" + "_" + c++] = g([6, 7, 0, 2])
map["办公室10" + "_" + c++] = g([7, 8, 0, 2])

map["楼梯" + "_" + c++] = g([2, 3, 3, 5])
map["" + "_" + c++] = g([2, 2.2, 3, 5]) //楼梯左边空的部分

map["" + "_" + c++] = g([3.5, 4, 3, 3.3]) //强电井
map["电梯" + "_" + c++] = g([3.5, 4, 3, 5])
map["" + "_" + c++] = g([3.5, 4, 4.7, 5]) //强电井

map["吧台" + "_" + c++] = g([4.5, 5, 3.2, 4.8])

map["" + "_" + c++] = g([5, 7, 3, 5]) //整个大块
arr = [
	[5.8, 4],
	[5, 4],
	[5, 5],
	[7, 5],
	[7, 4],
	[6.2, 4]
]
map["" + "_" + c++] = [
	[...arr, ...(arr.reverse())]
] //整个卫生间
map["卫生间" + "_" + c++] = g([5, 7, 4, 5])
map["风井" + "_" + c++] = g([5, 5.8, 3, 4])
map["无障碍" + "_" + c++] = g([6.2, 7, 3, 4])
map["" + "_" + c++] = g([5.8, 6.2, 3, 3.3]) //水暖井

map["楼梯" + "_" + c++] = g([7.5, 8, 3, 5])
map["" + "_" + c++] = g([7.5, 8, 4.7, 5]) //弱电井

map["开敞办公室" + "_" + c++] = g([8, 10, 0, 8])


//---------------------------------三层
sensorData[3] = [{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'left'
		},
		id: "lo3_1_1",
		platId: "lo3_1_1",
		name: "传感器",
		value: [1.9, 6.2]
	},
	{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'left'
		},
		id: "lo3_1_2",
		platId: "lo3_1_2",
		name: "传感器",
		value: [1.9, 1.5]
	},
	{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'right'
		},
		id: "o3_1",
		platId: "o3_1",
		name: "传感器",
		value: [2.5, 6.2]
	},
	{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'right'
		},
		id: "o3_2",
		platId: "o3_2",
		name: "传感器",
		value: [3.5, 6.2]
	},
	{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'right'
		},
		id: "o3_3",
		platId: "o3_3",
		name: "传感器",
		value: [6.5, 6.2]
	},
	{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'right'
		},
		id: "o3_4",
		platId: "o3_4",
		name: "传感器",
		value: [7.5, 6.2]
	},
	{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'right'
		},
		id: "o3_5",
		platId: "o3_5",
		name: "传感器",
		value: [2.5, 1.8]
	},
	{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'right'
		},
		id: "o3_6",
		platId: "o3_6",
		name: "传感器",
		value: [3.5, 1.8]
	},
	{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'right'
		},
		id: "o3_7",
		platId: "o3_7",
		name: "传感器",
		value: [4.5, 1.8]
	},
	{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'right'
		},
		id: "o3_8",
		platId: "o3_8",
		name: "传感器",
		value: [5.5, 1.8]
	},
	{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'right'
		},
		id: "o3_9",
		platId: "o3_9",
		name: "传感器",
		value: [6.5, 1.8]
	},
	{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'right'
		},
		id: "o3_10",
		platId: "o3_10",
		name: "传感器",
		value: [7.5, 1.8]
	},
	{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'right'
		},
		id: "m3_1",
		platId: "m3_1",
		name: "传感器",
		value: [5, 6.2]
	},
	{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'right'
		},
		id: "lo3_2_1",
		platId: "lo3_2_1",
		name: "传感器",
		value: [8.1, 6]
	},
	{
		label: {
			show: true,
			offset: [0, 0],
			color: '#38D0FB',
			fontSize: 12,
			formatter: item => {
				return item?.data?.platId || '-'
			},
			position: 'right'
		},
		id: "lo3_2_2",
		platId: "lo3_2_2",
		name: "传感器",
		value: [8.1, 1.5]
	},
]

map = mapData[3] = {}
// map["一层平面图" + "_" + c++] = [[label,label,label,label,label]]
map["" + "_" + c++] = g([0, 10, 0, 8]) //整个区域
map["开敞办公室" + "_" + c++] = g([0, 2, 0, 8])
map["办公室1" + "_" + c++] = g([2, 3, 6, 8])
map["办公室2" + "_" + c++] = g([3, 4, 6, 8])
map["会议室1" + "_" + c++] = g([4, 6, 6, 8])
map["办公室3" + "_" + c++] = g([6, 7, 6, 8])
map["办公室4" + "_" + c++] = g([7, 8, 6, 8])
map["办公室5" + "_" + c++] = g([2, 3, 0, 2])
map["办公室6" + "_" + c++] = g([3, 4, 0, 2])
map["办公室7" + "_" + c++] = g([4, 5, 0, 2])
map["办公室8" + "_" + c++] = g([5, 6, 0, 2])
map["办公室9" + "_" + c++] = g([6, 7, 0, 2])
map["办公室10" + "_" + c++] = g([7, 8, 0, 2])

map["楼梯" + "_" + c++] = g([2, 3, 3, 5])
map["" + "_" + c++] = g([2, 2.2, 3, 5]) //楼梯左边空的部分

map["" + "_" + c++] = g([3.5, 4, 3, 3.3]) //强电井
map["电梯" + "_" + c++] = g([3.5, 4, 3, 5])
map["" + "_" + c++] = g([3.5, 4, 4.7, 5]) //强电井

map["吧台" + "_" + c++] = g([4.5, 5, 3.2, 4.8])

map["" + "_" + c++] = g([5, 7, 3, 5]) //整个大块
arr = [
	[5.8, 4],
	[5, 4],
	[5, 5],
	[7, 5],
	[7, 4],
	[6.2, 4]
]
map["" + "_" + c++] = [
	[...arr, ...(arr.reverse())]
] //整个卫生间
map["卫生间" + "_" + c++] = g([5, 7, 4, 5])
map["风井" + "_" + c++] = g([5, 5.8, 3, 4])
map["无障碍" + "_" + c++] = g([6.2, 7, 3, 4])
map["" + "_" + c++] = g([5.8, 6.2, 3, 3.3]) //水暖井

map["楼梯" + "_" + c++] = g([7.5, 8, 3, 5])
map["" + "_" + c++] = g([7.5, 8, 4.7, 5]) //弱电井

map["开敞办公室" + "_" + c++] = g([8, 10, 0, 8])

let geoJson = {
	"type": "FeatureCollection",
	"features": []
}

export function getGeoJsonOf(floorId) {
	if (!mapData[floorId]) return []
	geoJson.features = []
	for (let key in mapData[floorId]) {
		let name = key.split("_")[0]
		let tmp = {
			"type": "Feature",
			"properties": {
				"stroke": "#555555",
				"stroke-width": 2,
				"stroke-opacity": 1,
				"fill": "#555555",
				"fill-opacity": 0.5,
				"name": name
			},
			"geometry": {
				"type": "Polygon",
				"coordinates": mapData[floorId][key]
			}
		}
		geoJson.features.push(tmp)
	}
	return geoJson
}

export function getSensorJsonOf(floorId) {
	if (!sensorData[floorId]) return []
	return sensorData[floorId]
}

export const option = {
	baseOption: {
		geo: {
			show: true,
			map: '',
			roam: false, //控制鼠标缩放 平移
			zoom: 1.1,
			aspectScale: 6 / 2, //长宽比
			center: [5, 4],
			label: {
				show: true,
				color: '#fff',
				fontSize: 12
			},
			itemStyle: {
				normal: {
					borderColor: 'rgba(147, 235, 248, 1)', //
					borderWidth: 1,
					areaColor: {
						type: 'radial',
						x: 0.5,
						y: 0.5,
						r: 0.8,
						colorStops: [{
							offset: 0,
							color: 'rgb(103,145,196,.2)' // 0% 处的颜色
						}, {
							offset: 1,
							color: 'rgba(103,157,219,0.1)' // 100% 处的颜色
						}]
					},
					shadowColor: 'rgba(128, 217, 248, 1)',
					shadowOffsetX: -2,
					shadowOffsetY: 2,
					shadowBlur: 50
				},
				emphasis: {
					areaColor: 'rgba(103,157,219,0.1)', //
					borderWidth: 2
				}
			}
		},
		series: [
			//地图中闪烁的点
			{
				name: '传感器',
				type: 'effectScatter',
				coordinateSystem: 'geo',
				data: [],
				symbolSize: 5,
				itemStyle: {
					normal: {
						color: '#555555', //默认都不存在
					},
				}
			},
			//地图中闪烁的点
			{
				name: '传感器',
				type: 'effectScatter',
				coordinateSystem: 'geo',
				data: [],
				symbol: 'roundRect', //气泡
				symbolSize: 5,
				showEffectOn: 'render',
				rippleEffect: {
					brushType: 'stroke'
				},
				tooltip: {
					trigger: 'item'
				},
				emphasis: {
					itemStyle: {
						shadowBlur: 10, // 图形阴影的模糊大小
						shadowOffsetX: 0, // 阴影水平方向上的偏移距离
						shadowColor: 'rgba(0, 0, 0, 0.5)' // 阴影颜色
					},
					label: {
						show: true,
						formatter: function(params) {
							return JSON.stringify(params.data?.val || "");
						},
						color: '#cd0000'
					}
				},
				itemStyle: {
					normal: {
						color: '#33ff33',
						shadowBlur: 10,
						shadowColor: '#565656'
					},
				}
			}
		]
	}
}
